 Ext.define('DCApp.view.doc.Detail', {
    extend: 'DCApp.view.Detail',
    alias: 'widget.docdetail',
    
    requires: ['DCApp.ux.ComboTree','Ext.form.field.Tag'],
    bind: {
        title: '文稿 - 【{theObj.id}】'
    },
    
    tbar: ['->',{
    	text:'>>>显示更多',
    	handler:'onMore'
    },{
        text: '上一条',
        handler: 'onPrev',
        bind: {
            hidden: '{!showprev}'
        }
    },{
        text: '下一条',
        handler: 'onNext',
        bind: {
            hidden: '{!shownext}'
        }
    },{
        text: '保存',
        handler: 'onSaveClick',
        bind: {
            hidden: '{!showsave}'
        }
    },{
        text: '返回',
        handler: 'onBackClick',
        bind: {
            hidden: '{!showreturn}'
        }
    }],
    
    componentCls: 'doc-detail',
    bodyPadding: 0,
    
    controller: 'detail',
    
    moreItems:[
    {
		title : '相关文物',
		margin : '0 0 10 0',
		cls : 'nav_pos',
		layout : 'fit',
		items : [
			{
			 bind: {
				 store:'{theObj.relics}'
			 },
			 xtype : 'reliclist',
			 plugins: null,
			 tbar: ['->',{
			        text: '关联',
			        handler: 'onRelList'
			    },{
			        text: '删除',
			        handler: 'onRelDel' 
			    }]
			}
		]							
	}],
    afterRender: function(ct, position) {
    	var imgpanel = this.down('imgpanel');
    	if(imgpanel){
	    	var tb = imgpanel.down('toolbar[dock=top]');
	    	tb.insert(1,[{
	    		text:'插入'
	    	}]);
    	}
    	var attachpanel = this.down('attachpanel');
    	if(attachpanel){
	    	var tb = attachpanel.down('toolbar[dock=top]');
	    	tb.insert(1,[{
	    		text:'插入'
	    	}]);
    	}
    	this.callParent();
    },
    items: [{
     listeners: {
		render: function(p){
			p = p.getEl();
			var me= this.up();
			me.h0=p.getHeight();
		    p.on('scroll', function(e, t){
		    	me.onscroll(t.scrollTop,t.clientHeight);
		    }, p);
		  }
		},
    	title: 'Panel 0',
    	padding:'0 0 50 0', 
        flex: 2,
        frame: false,
        xtype: 'container',
        layout: 'anchor',
        style: {
            overflow: 'auto'
        },
        items: [
                {
                    title: '文稿信息',
                    margin: '0 0 10 0',
                    cls:'nav_pos',
                    reference: 'form',
                    bodyPadding: 10,
                    fieldDefaults: {
                        labelAlign: 'right',
                        labelWidth: 100,
                        padding:3
                    },
                    defaults: {
                        anchor: '100%'
                    },
                    xtype: 'form',
                    items: [
                    	{
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [
                        	{
                        		flex: 2,
		                        xtype: 'textfield',
		                        fieldLabel: '题名',
		                        bind: '{theObj.title}',
		                        publishes: ['value']
                    		},
                    		 DCApp.Cfg.getEditorField('登记人','{theObj.dcEditor0}')
                    		]
                    },
                    		
                    {
                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [
                        DCApp.Cfg.getAuthorField('撰稿人','{theObj.author}'), {
                            flex: 2,
                            fieldLabel: '约稿人',
                            xtype: 'displayfield',
                            bind: '{theObj.linkMan}'
                        }]
                    },
                    {

                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [
                        {
							flex: 2,
							xtype: 'combotree',
							fieldLabel: '细分类',
							bind: '{theObj.subtype}',
							listeners:{
					                        	focus:function( fld, evt, eOpts ){
					                        		fld.onTriggerClick();
					                        	}
					                        },
							id : 'name',  
							name : 'name',  
							hiddenName : 'hiddenName',  
							emptyText :'请选择',
							storeUrl : '/getTreeData/Doc/subtype',
							cascade : 'child',//级联方式:1.child子级联;2.parent,父级联,3,both全部级联  
							checkModel:'double',//当json数据为不带checked的数据时只配置为single,带checked配置为double为单选,不配置为多选  
							rootId : '1',  
							rootText : 'DRP',  
							treeNodeParameter : '',
							filters:{
							property:'id',
							operator:'gt',
							value:DCApp.Cfg.ID_START},
							publishes: ['value']
						}
                        /*{
                            flex: 2,
                            fieldLabel: '细分类',
                            bind: '{theObj.subtype}',
                            xtype: 'combobox',
                            triggerAction:'all',
                            typeAhead :true,
                           	minChars:1,
                           	//lazyInit:false,
                           	emptyText :'请选择',
                            queryParam : 'kw',
 				          	typeAhead :true,
                            valueField: 'name',
                            displayField: 'name',
                            store: DCApp.Cfg.getDistinctStore('com.cl.entity.Doc','subtype',
                            	{
                                property:'id',
                                operator:'gt',
                                value:DCApp.Cfg.ID_START
                            })
                        }*/, { 
                        	flex: 2,
                            fieldLabel: '正文字数',
                            name:'dcTxtwords',
                            bind: '{theObj.dcTxtwords}',
                            xtype: 'numberfield'
                     }]
                                        	
                    },
                    {

                        xtype: 'container',
                        layout: 'hbox',
                        combineErrors: true,
                        defaultType: 'textfield',
                        items: [
                        DCApp.Cfg.getUserField('初审','{theObj.dcEditor1}'),
                        DCApp.Cfg.getUserField('终审','{theObj.dcEditor2}')
                        ]
                     },
                    {  
	                        xtype: 'fileupload',
	                        name: 'file1',
	                        fieldLabel: '文稿上传',
	                        height:'auto!important',
	                        bind: '{theObj.dcDraft}',
	                        listeners:{
	                        	'uploaded':DCApp.Cfg.parseWord
	                        }
	                        
	                    },{
            	xtype: 'htmleditor',
            	//plugins:[{ptype: 'word'}],
            	bind: {
                    value: '{theObj.description}'
                },
            	defaultValue :'',
            	plugins:[{ptype: 'word'}],
            	enableColors: false,
        		enableAlignments: false,
            	//publishes: ['value'],
            	fieldLabel: '正文'
               }]
                },
                {
                    title: '影像列表',
                    margin: '0 0 10 0',
                    cls:'nav_pos',
                    layout:'fit',
                    items:[{
                    	bind: '{theObj.images}',
                    	xtype:'imgpanel'
                    }]                    
                },
                {
                    title: '附件列表',
                    cls:'nav_pos',
                    layout:'fit',
                    items:[{
                    	bind:'{theObj.ceAttachments}',
                    	xtype:'attachpanel'
                    }]                    
                }
            ]
        }]
});
